﻿using System;
using System.Collections.Generic;
using System.Text;
using Projecturo.ProjecturoClient.Test.TestData;
using System.Collections;

namespace Projecturo.ProjecturoClient.Test.Persistence
{
    public static class MockDatabase
    {
        private static List<TestModel> testModelList = new List<TestModel>();

        public static void Add(object model)
        {
            String typeName = model.GetType().Name;
            switch(typeName)
            {
                case "TestModel":
                    if (!testModelList.Contains(model as TestModel))
                        testModelList.Add(model as TestModel);
                    break;
                default:
                    throw new TypeLoadException("Could not handle type " + model.GetType().FullName);
            }
        }

        public static object Get(Type t, long id)
        {
            String typeName = t.Name;
            switch(typeName)
            {
                case "TestModel":
                    return testModelList.Find(tm => tm.Id == id);
                default:
                    throw new TypeLoadException("Could not handle type " + t.FullName);
            }
        }

        public static IList GetList(Type t)
        {
            String typeName = t.Name;
            switch(typeName)
            {
                case "TestModel":
                    return testModelList;
                default:
                    throw new TypeLoadException("Could not handle type " + t.FullName);
            }
        }
    }
}
